package com.omega_r.omegarecyclerview.expandable_example;

import com.omega_r.omegarecyclerview.ResourceTable;
import com.omega_r.omegarecyclerview.expandable_example.core.ExpandableAbility;
import com.omega_r.omegarecyclerview.expandable_example.support_sticky.DefaultStickyExpandableAbility;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;

public class ChooseExpandableAbility extends Ability implements Component.ClickedListener {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_choose_expandable);
        findComponentById(ResourceTable.Id_button_core).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_sticky_support).setClickedListener(this);
    }

    @Override
    public void onClick(Component component) {
        Intent intent = new Intent();
        Operation operation = null;
        switch (component.getId()) {
            case ResourceTable.Id_button_core:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(ExpandableAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_sticky_support:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(DefaultStickyExpandableAbility.class.getName())
                        .build();
                break;
        }
        intent.setOperation(operation);
        startAbility(intent);
    }
}
